
package com.j2eefast.produce.pms.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.framework.sys.entity.SysUserEntity;
import com.j2eefast.framework.utils.Constant;
import com.j2eefast.framework.utils.UserUtils;
import com.j2eefast.produce.pms.entity.PmsChargeStandardListEntity;
import com.j2eefast.produce.pms.entity.PmsTestEnterListEntity;
import com.j2eefast.produce.pms.mapper.PmsChargeStandardListMapper;
import com.j2eefast.produce.pms.mapper.PmsTestEnterListMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>收费标准列表</p>
 *
 * @author: summer
 * @date: 2021-05-29 16:47
 * @web: http://www.letukeji.cn
 * @version: 1.0.1
 */
@Service
@Transactional(readOnly = true)
public class PmsChargeStandardListService extends ServiceImpl<PmsChargeStandardListMapper, PmsChargeStandardListEntity> {

	@Resource
	protected PmsChargeStandardListMapper pmsChargeStandardListMapper;


	/**
	 * 页面展示查询翻页
	 */
	public PageUtil findPage(Map<String, Object> params) {
		String testingProject = (String) params.get("testingProject");
		String chargeUnit = (String) params.get("chargeUnit");
		String price = (String) params.get("price");
		String remark = (String) params.get("remark");
		String testingProject2 = (String) params.get("testingProject2");
		String chargeUnit2 = (String) params.get("chargeUnit2");
		Page<PmsChargeStandardListEntity> page = pmsChargeStandardListMapper.findPage(
				new Query<PmsChargeStandardListEntity>(params).getPage(),
				StrUtil.nullToDefault(testingProject,""),
				StrUtil.nullToDefault(chargeUnit,""),
				StrUtil.nullToDefault(price,""),
				StrUtil.nullToDefault(remark,""),
				StrUtil.nullToDefault(testingProject2,""),
				StrUtil.nullToDefault(chargeUnit2,""),
				(String) params.get(Constant.SQL_FILTER));
		return new PageUtil(page);
	}

	public List<PmsChargeStandardListEntity> findList(Map<String, Object> params) {
		String testingProject = (String) params.get("testingProject");
		String chargeUnit = (String) params.get("chargeUnit");
		String price = (String) params.get("price");
		String remark = (String) params.get("remark");
		List<PmsChargeStandardListEntity> page = pmsChargeStandardListMapper.findList(
				new Query<PmsChargeStandardListEntity>(params).getPage(),
				StrUtil.nullToDefault(testingProject,""),
				StrUtil.nullToDefault(chargeUnit,""),
				StrUtil.nullToDefault(price,""),
				StrUtil.nullToDefault(remark,""),
				(String) params.get(Constant.SQL_FILTER));
		return page;
	}

	public List<PmsChargeStandardListEntity> getEntrustList(Map<String, Object> params){
		String productName=(String)params.get("productName");
		return pmsChargeStandardListMapper.getEntrustList(productName);
	}


	@Transactional(rollbackFor = Exception.class)
	public boolean deleteByIds(Long[] ids) {

		return pmsChargeStandardListMapper.deleteByIds(ids);

	}
	@Transactional(rollbackFor = Exception.class)
	public boolean updateCheck(Long id) {
		Long userId= UserUtils.getUserInfo().getId();

		return pmsChargeStandardListMapper.updateCheck(id ,userId);

	}
	public SysUserEntity getSysById(@Param("userId")Long userId){
		return pmsChargeStandardListMapper.getSysById(userId);
	}

	public List<PmsChargeStandardListEntity> selectChargeStandardList(String [] arr){
		return pmsChargeStandardListMapper.selectChargeStandardList(arr);
	}

}
